<!-- S search -->
<app-search-bar
  [submitLoading]="tableParams.loading"
  [searchOptions]="searchOptions"
  labelFlex="80px"
  (onSearch)="queryResetData($event)"
  (onReset)="queryResetData($event)"
>
</app-search-bar>
<!-- E search -->

<nz-card class="m-t-4">
  <div class="opera-wrap">
    <button
      nz-button
      nzType="primary"
      [nzLoading]="exportLoading"
      (click)="exportTable()"
    >导出</button>
  </div>

  <div class="pagination-wrap-position p-t-10">
    <nz-table
      #basicTable
      nzSize="small"
      nzShowSizeChanger
      nzShowQuickJumper
      nzBordered
      [nzWidthConfig]="tbWidthConfig"
      [nzScroll]="{ x: '1100px' }"
      [nzFrontPagination]="false"
      [nzLoadingDelay]="100"
      [nzLoading]="tableParams.loading"
      [nzData]="tableParams.tableData"
      [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
      [nzTotal]="tableParams.total"
      [nzPageIndex]="tableParams.page"
      [nzPageSize]="tableParams.pageSize"
      [nzShowTotal]="totalTemplate"
      (nzPageIndexChange)="onPageIndexChange($event)"
      (nzPageSizeChange)="onPageSizeChange($event)"
    >
      <thead>
        <tr>
          <th nzAlign="center" colspan="9">SN信息</th>
          <th nzAlign="center" colspan="5">商品信息</th>
          <th nzAlign="center" rowspan="2" nzRight>操作</th>
        </tr>
        <tr>
          <th nzAlign="center">SN码</th>
          <th nzAlign="center">SN状态</th>
          <!-- <th nzAlign="center">SN类型</th> -->
          <th nzAlign="center">所在仓库</th>
          <th nzAlign="center">所在库位</th>
          <th nzAlign="center">SN品质</th>
          <th nzAlign="center">入库关联单号</th>
          <th nzAlign="center">入库时间</th>
          <th nzAlign="center">出库关联单号</th>
          <th nzAlign="center">出库时间</th>
          <th nzAlign="center">商品编码</th>
          <th nzAlign="center">商品状态</th>
          <th nzAlign="center">商品名称</th>
          <th nzAlign="center">商品69码</th>
          <th nzAlign="center">商品品牌</th>
        </tr>
      </thead>

      <tbody>
        <tr *ngFor="let data of basicTable.data; let index = index;">
          <!-- SN码 -->
          <td nzAlign="center">{{ data.code || '-' }}</td>
          <!-- SN状态 -->
          <td nzAlign="center">
            <span [ngStyle]="{'color': data.state | storeSncodeStatus: 'color'}">
              {{ data.state | storeSncodeStatus: 'label' }}
            </span>
          </td>
          <!-- SN类型 -->
          <!-- <td nzAlign="center">
            <span>
              {{ data.type === 0 ? '入库单' : (data.type === 1 ? '出库单' : '-') }}
            </span>
          </td> -->
          <!-- 所在仓库 -->
          <td nzAlign="center">
            {{ filterText(warehouseOptions, data.whId) }}
          </td>
          <!-- 所在库位 -->
          <td nzAlign="center">
            {{ filterText(locationOptions, data.libraryId) }}
          </td>
          <!-- SN品质 -->
          <td nzAlign="center">
            <span>
              {{ data.quality === 0 ? '不良品' : '良品' }}
            </span>
          </td>
          <!-- 入库关联单号 -->
          <td nzAlign="center">{{ data.warehousingNumber || '-' }}</td>
          <!-- 入库时间 -->
          <td nzAlign="center">{{ data.warehousingTime || '-' }}</td>
          <!-- 出库关联单号 -->
          <td nzAlign="center">{{ data.deliveryNumber || '-' }}</td>
          <!-- 出库时间 -->
          <td nzAlign="center">{{ data.deliveryTime || '-' }}</td>
          <!-- 商品编码 -->
          <td nzAlign="center">{{ data.goodsCode || '-' }}</td>
          <!-- 商品状态 -->
          <td nzAlign="center">
            <span [ngStyle]="{'color': data.goodsCode === 0 ? '#909399' : '#67C23A'}">
              {{ data.goodsCode === 0 ? '禁用' : '启用' }}
            </span>
          </td>
          <!-- 商品名称 -->
          <td nzAlign="center">{{ data.goodsName || '-' }}</td>
          <!-- 商品69码 -->
          <td nzAlign="center">{{ data.goodsCodeTwo || '-' }}</td>
          <!-- 商品品牌 -->
          <td nzAlign="center">{{ data.goodsBrand || '-' }}</td>
          <!-- 操作 -->
          <td nzAlign="center" nzRight>
            <button
              nz-button
              nzType="link"
              nzSize="small"
              (click)="showFollowModal(data)"
            >跟进</button>
          </td>
        </tr>
      </tbody>
    </nz-table>

    <!-- 分页template -->
    <ng-template #totalTemplate let-total>共有 {{ total }} 条</ng-template>
  </div>
</nz-card>

<!-- 跟进Component -->
<app-follow-up #followUpRef [initParams]="initParams" [ohterParams]="{ type: 0, sourceType: 99 }"></app-follow-up>